<?php require 'header.php'; ?>
		<div id="main" class="container">

			<div class="section row entries bg-primary section-no-margin-bottom">

				<article class="entry style-grid style-hero hero-sm-largest type-post col-sm-12 col-md-6 colheight-sm-1 colheight-md-2 colheight-lg-2 colheight-xl-2">
					<?php 
						$select_head_news = $conn->query("SELECT * FROM `news` WHERE `section` = 'news' ORDER BY pub_date DESC LIMIT 1");
						$row_head_news = $select_head_news->fetch();
					?>
					<div class="ribbon ribbon-pulled ribbon-small ribbon-highlight">
						<a href="#">News</a>
					</div>

					<header class="entry-header">
						<h3 class="entry-title"><a href="/post/<?php echo $row_head_news['id']; ?>"><?php echo $row_head_news['title']; ?></a> </h3>
						<div class="entry-meta">
							<?php 
											$select_news_author = $conn->query("SELECT * FROM `users` WHERE id = '".$row_head_news['author_id']."'");
											$row_news_author = $select_news_author->fetch();
										?>
										<span class="entry-author">by <a><?php echo $row_news_author['firstname'] . " " . $row_news_author['lastname']; ?></a></span>
										
						</div>
					</header>

					<figure class="entry-thumbnail">

						<a href="#" class="overlay overlay-primary"></a>

						<!-- to disable lazy loading, remove data-src and data-src-retina -->
						<img src="author/images/<?php echo $row_head_news['img_name']; ?>" width="680" height="452" class="" alt="">

								<!--fallback for no javascript browsers-->
								<noscript>
									<img src="author/images/<?php echo $row_head_news['img_name']; ?>" alt="">
								</noscript>

					</figure>

				</article>

				<article class="entry style-grid style-hero type-post col-md-6 col-lg-3 colheight-sm-1">
					
					<div class="ribbon ribbon-pulled ribbon-small ribbon-highlight">
						<a href="#">Reviews</a>
					</div>
					<?php 
						$select_head_reviews = $conn->query("SELECT * FROM `news` WHERE `section` = 'review' ORDER BY pub_date DESC LIMIT 1");
						$row_head_reviews = $select_head_reviews->fetch();
					?>
					<header class="entry-header">
						<h3 class="entry-title"><a href="/post/<?php echo $row_head_reviews['id']; ?>"><?php echo $row_head_reviews['title']; ?></a> </h3>
						<div class="entry-meta">
							<?php 
											$select_news_author = $conn->query("SELECT * FROM `users` WHERE id = '".$row_head_reviews['author_id']."'");
											$row_news_author = $select_news_author->fetch();
										?>
										<span class="entry-author">by <a><?php echo $row_news_author['firstname'] . " " . $row_news_author['lastname']; ?></a></span>
										
						</div>
					</header>
					
					<figure class="entry-thumbnail">

						<a href="#" class="overlay overlay-primary"></a>

						<!-- to disable lazy loading, remove data-src and data-src-retina -->
						<img src="author/images/<?php echo $row_head_reviews['img_name']; ?>" width="680" height="452" class="" alt="">

								<!--fallback for no javascript browsers-->
								<noscript>
									<img src="author/images/<?php echo $row_head_reviews['img_name']; ?>" alt="">
								</noscript>

					</figure>

				</article>

				<article class="entry style-grid style-hero type-post col-md-6 col-lg-3 colheight-sm-1">
					
					<div class="ribbon ribbon-pulled ribbon-small ribbon-highlight">
						<a href="#">How To</a>
					</div>
<?php 
						$select_head_howtos = $conn->query("SELECT * FROM `news` WHERE `section` = 'howto' ORDER BY pub_date DESC LIMIT 1");
						$row_head_howtos = $select_head_howtos->fetch();
					?>
					<header class="entry-header">
						<h3 class="entry-title"><a href="/post/<?php echo $row_head_howtos['id']; ?>"><?php echo $row_head_howtos['title']; ?></a> </h3>
						<div class="entry-meta">
							<?php 
											$select_news_author = $conn->query("SELECT * FROM `users` WHERE id = '".$row_head_howtos['author_id']."'");
											$row_news_author = $select_news_author->fetch();
										?>
										<span class="entry-author">by <a><?php echo $row_news_author['firstname'] . " " . $row_news_author['lastname']; ?></a></span>
										
						</div>
					</header>
					
					<figure class="entry-thumbnail">

						<a href="#" class="overlay overlay-primary"></a>

						<!-- to disable lazy loading, remove data-src and data-src-retina -->
						<img src="author/images/<?php echo $row_head_howtos['img_name']; ?>" width="680" height="452" class="" alt="">

								<!--fallback for no javascript browsers-->
								<noscript>
									<img src="author/images/<?php echo $row_head_howtos['img_name']; ?>" alt="">
								</noscript>

					</figure>

				</article>

				<article class="entry style-grid style-hero type-post col-md-6 col-lg-3 colheight-sm-1">
					
					<div class="ribbon ribbon-pulled ribbon-small ribbon-highlight">
						<a href="#">Articles</a>
					</div>
<?php 
						$select_head_articles = $conn->query("SELECT * FROM `news` WHERE `section` = 'article' ORDER BY pub_date DESC LIMIT 1");
						$row_head_articles = $select_head_articles->fetch();
					?>
					<header class="entry-header">
						<h3 class="entry-title"><a href="/post/<?php echo $row_head_articles['id']; ?>"><?php echo $row_head_articles['title']; ?></a> </h3>
						<div class="entry-meta">
							<?php 
											$select_news_author = $conn->query("SELECT * FROM `users` WHERE id = '".$row_head_articles['author_id']."'");
											$row_news_author = $select_news_author->fetch();
										?>
										<span class="entry-author">by <a><?php echo $row_news_author['firstname'] . " " . $row_news_author['lastname']; ?></a></span>
										
						</div>
					</header>
					
					<figure class="entry-thumbnail">

						<a href="#" class="overlay overlay-primary"></a>

						<!-- to disable lazy loading, remove data-src and data-src-retina -->
						<img src="author/images/<?php echo $row_head_articles['img_name']; ?>" width="680" height="452" class="" alt="">

								<!--fallback for no javascript browsers-->
								<noscript>
									<img src="author/images/<?php echo $row_head_articles['img_name']; ?>" alt="">
								</noscript>

					</figure>

				</article>

				<article class="entry style-grid style-hero type-post col-md-6 col-lg-3 colheight-sm-1">
					
					<div class="ribbon ribbon-pulled ribbon-small ribbon-highlight">
						<a href="#">CNET</a>
					</div>
					<?php 
					$feed = file_get_contents("http://www.cnet.com/rss/all/");
					$xml = new SimpleXmlElement($feed);
					$count=0;
					foreach ($xml->channel->item as $entry){
					?>
					<header class="entry-header">
						<h3 class="entry-title"><a href="<?php echo $entry->link; ?>" target="_blank"><?php echo $entry->title; ?></a> </h3>
						<?php 
						$dc = $entry->children("http://purl.org/dc/elements/1.1/");
						$media = $entry->children("http://search.yahoo.com/mrss/");
				  		$img = $media->thumbnail->attributes()->url;
						?>
						<div class="entry-meta">
							<span class="entry-author"> by <a href="#"><?php echo $dc->creator; ?></a></span>
						</div>
					</header>
					
					<figure class="entry-thumbnail">

						<a href="#" class="overlay overlay-primary"></a>

						<!-- to disable lazy loading, remove data-src and data-src-retina -->
						<img src="<?php echo $img; ?>" width="480" height="280" alt="">

						<!--fallback for no javascript browsers-->
						<noscript>
							<img src="<?php echo $img; ?>" alt="">
						</noscript>

					</figure>
					<?php 
					$count++;
				  if($count==1){
				  	break;
				  }
				} ?>

				</article>

			</div>

			<div id="content" class="content section row">

				<div class="row sub-cat-list">
					<ul>
						<a href="http://tech.af/cats/3"><li><i class="fa fa-globe"></i> <span>Internet</span></li></a>	
						<a href="http://tech.af/cats/1"><li><i class="fa fa-cloud"></i> <span>Software</span></li></a>					
						<a href="http://tech.af/cats/4"><li><i class="fa fa-sitemap"></i> <span>Networks</span></li></a>
						<a href="http://tech.af/cats/5"><li><i class="fa fa-mobile"></i> <span>Mobile</span></li></a>
						<a href="http://tech.af/cats/6"><li><i class="fa fa-graduation-cap"></i> <span>Sci-Tech</span></li></a>
						<a href="http://tech.af/cats/7"><li style="border-right: none;"><i class="fa fa-shield"></i> <span>Security</span></li></a>
					</ul>
				</div>
				<div class="col-md-8 bg-base col-lg-8 col-xl-9">

					<div class="ribbon ribbon-highlight">
						<ol class="breadcrumb ribbon-inner">
							<li class="active">Home</li>
						</ol>
					</div>
					
					<div class="entries">
						<?php
							$select_news = $conn->query("SELECT * FROM `news` ORDER BY pub_date DESC LIMIT 0,10");
							while($row_news = $select_news->fetch()){
						?>
						<article class="entry style-media media type-post">

							<figure class="media-object pull-left entry-thumbnail my-entry-thumbnail hidden-xs">

								<!-- to disable lazy loading, remove data-src and data-src-retina -->
								<img src="author/images/<?php echo $row_news['img_name']; ?>" width="230" height="230" class="" alt="">

								<!--fallback for no javascript browsers-->
								<noscript>
									<img src="author/images/<?php echo $row_news['img_name']; ?>" alt="">
								</noscript>

							</figure>

							<div class="media-body">

								<header class="entry-header">
									<h3 class="entry-title">
										<a href="/post/<?php echo $row_news['id']; ?>" rel="bookmark"><?php echo $row_news['title']; ?></a>
									</h3>

									<div class="entry-meta">
										<?php 
											$select_news_author = $conn->query("SELECT * FROM `users` WHERE id = '".$row_news['author_id']."'");
											$row_news_author = $select_news_author->fetch();
										?>
										<span class="author">by <a><?php echo $row_news_author['firstname'] . " " . $row_news_author['lastname']; ?></a></span>
										
										<span class="entry-date">/ <a href="#"><time datetime="2013-07-04T23:26:34+00:00"><?php echo @date("F jS Y",strtotime($row_news['pub_date'])); ?></time></a></span>
										<?php 
											$select_news_cat = $conn->query("SELECT * FROM news_categories WHERE id = '".$row_news['category_id']."'");
											$row_news_cat = $select_news_cat->fetch();
										?>
										<span class="category">/ <a href="/cats/<?php echo $row_news_cat['id']; ?>"><?php echo $row_news_cat['category_name']; ?></a></span>
									</div>
								</header>

								<p>
									<?php echo substr($row_news['description'],0,150); ?><a href="/post/<?php echo $row_news['id']; ?>" class="more-link">Continue Reading<i class="fa fa icon-long-arrow-right"></i></a>
								</p>

							</div>

						</article>
						<?php } ?>
								
					</div><!--/.entris-->

				</div><!--/.col-md-8.col-lg-8.col-xl-9-->

				<div class="sidebar col-md-4 col-lg-4 col-xl-3">

					<aside class="widget">
						<?php require 'sidebar-mostviewed.php'; ?>

					</aside><!--/.widget-->

					<aside id="reviewCarousel" class="widget carousel slide">

						<?php require 'rssbar.php'; ?>
					</aside><!--/.widget.carousel-->
					<aside class="widget">
						<?php require 'sidebar-ads.php'; ?>
					</aside><!--/.widget-->

				</div><!--/.sidebar col-md-4 col-lg-4 col-xl-3-->

			</div><!--/#content-->


			
		</div><!--#main.container-->

		<?php require 'footer.php'; ?>